﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Gnosis.Babel;

namespace Gnosis.SQLite.Columns
{
    public class ColumnPrimaryKey
        : Constraint, IColumnConstraint
    {
        public ColumnPrimaryKey()
            : this(ConstraintName.Default)
        {
        }

        public ColumnPrimaryKey(ConstraintName name)
            : this(name, new List<IExpression>())
        {
        }

        public ColumnPrimaryKey(ConstraintName name, IList<IExpression> expressions)
            : base(name, "PRIMARY KEY", expressions)
        {
        }

        public static ColumnPrimaryKey Ascending()
        {
            return Ascending(ConstraintName.Default);
        }

        public static ColumnPrimaryKey Ascending(ConstraintName name)
        {
            return new ColumnPrimaryKey(name, new List<IExpression> { Direction.Ascending });
        }

        public static ColumnPrimaryKey AscendingAutoIncrement()
        {
            return AscendingAutoIncrement(ConstraintName.Default);
        }

        public static ColumnPrimaryKey AscendingAutoIncrement(ConstraintName name)
        {
            return new ColumnPrimaryKey(name, new List<IExpression> { Direction.Ascending, new AutoIncrement() });
        }

        public static ColumnPrimaryKey Descending()
        {
            return Descending(ConstraintName.Default);
        }

        public static ColumnPrimaryKey Descending(ConstraintName name)
        {
            return new ColumnPrimaryKey(name);
        }
    }
}
